/** From Prototype **/ 
var Class = {
	create: function() {
		return function() { 
			this.initialize.apply(this, arguments);
		}
	}
}; 
Function.prototype.bind = function() { 
	var __method = this, args = $A(arguments), object = args.shift();
	return function() { 
		return __method.apply(object, args.concat($A(arguments)));
	}
}; 
var $A = function(it) { 
	if (!it) return [];
	if (it.toArray) return it.toArray();
	var re = [];
	for (var i = 0; i < it.length; i++) 
		re.push(it[i]);
	return re;
};
/** Compatible **/
if (!Array.prototype.indexOf) { 
	Array.prototype.indexOf = function(elt) { 
		var len=this.length;
		var from=Number(arguments[1]) || 0;
		from= (from < 0) ? Math.ceil(from) : Math.floor(from);
		if (from<0) 
			from += len;
		for (;from<len;from++) {
			if (from in this && this[from] === elt)
				return from;
		}
		return -1;
	};
}
Array.prototype.each = function (iterator) {
	var index = 0;
	try {
		for (var i = 0, length = this.length; i < length; i++)
			iterator(this[i], index++);
	} catch (e) {
		if (e != $break) throw e;
	}
	return this;
}

String.prototype.camelize = function() {
	var parts = this.split('_'), len = parts.length;

	var camelized = parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
	
	for (var i = 1; i < len; i++)
		camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
	
	return camelized;
};

jQuery.fn.hash = function(ke,va) {
	var hash = [];
	if(ke != null) { 
		$(this).each(function() {
			hash[$(this).attr(ke)] = ((va != null) ? $(this).attr(va) : this);
		});
	} else {
		$(this).each(function() {
			hash[this] = this;
		});
	}
	return hash;
};

